package com.skyline.attraction.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.attraction.model.Raty;
import com.skyline.attraction.type.RatyType;

public class RatyMapper implements RowMapper<Raty> {

	private final static String COLUMN_ID = "id";
	private final static String COLUMN_TARID = "tarId";
	private final static String COLUMN_TYPE = "type";
	private final static String COLUMN_USERID = "userId";
	private final static String COLUMN_RATYSTAR = "ratyStar";
	private final static String COLUMN_RATYTIME = "ratyTime";

	private final static RatyMapper MAPPER = new RatyMapper();

	public static RatyMapper getMapper() {
		return MAPPER;
	}

	public Raty mapRow(ResultSet rs, int rowNum) throws SQLException {
		Raty raty = new Raty();
		try {
			raty.setId(rs.getLong(COLUMN_ID));
			raty.setTarId(rs.getLong(COLUMN_TARID));
			raty.setType(RatyType.valueOf(rs.getString(COLUMN_TYPE)));
			raty.setUserId(rs.getLong(COLUMN_USERID));
			raty.setRatyStar(rs.getInt(COLUMN_RATYSTAR));	
			raty.setRatyTime(rs.getDate(COLUMN_RATYTIME));
			
		} catch (Exception e) {
				return null;
		}
		return raty;
	}

}
